import modules from '@/store/common';
import { IState, ITodo } from '@/typings';
import { Commit } from 'vuex';
const { types } = modules();
const { SET_TODO, SET_TODO_LIST, REMOVE_TODO, SET_TODO_STATUS, SET_TODO_DOING } = types as any;

interface ICtx {
  commit: Commit,
  state: IState
}
export default {
  [SET_TODO]({ commit, state}: ICtx, todo: ITodo):void {
    commit(SET_TODO, todo)
  },
  [SET_TODO_LIST]({ commit, state}: ICtx, todoList: ITodo[]):void {
    commit(SET_TODO_LIST, todoList)
  },
  [REMOVE_TODO]({ commit, state}: ICtx, id: number):void {
    commit(REMOVE_TODO, id)
  },
  [SET_TODO_STATUS]({ commit, state}: ICtx, id: number):void {
    commit(SET_TODO_STATUS, id)
  },
  [SET_TODO_DOING]({ commit, state}: ICtx, id: number):void {
    commit(SET_TODO_DOING, id)
  },
}